home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 9943 / 9943.xpi / content / options.js next >
Text File  |  2009-06-05  |  6KB  |  204 lines

  1.  
  2. var searchcloudlet_options={
  3.     doOK:function()
  4.     {
  5.       //tagcloudjs_PrefManager
  6.       var toCheck=['websearch','news','blogsearch','scholar','products','yahoo.web','yahoo.news','twitter.user.my','twitter.user.other','twitter.search'];
  7.       var pref='';
  8.       for (var i=0;i<toCheck.length;i++)
  9.       {
  10.         var chk=document.getElementById(toCheck[i]);
  11.         if (!chk.checked)
  12.         {
  13.           pref+=toCheck[i]+' ';
  14.           if ('twitter.search'==toCheck[i])
  15.           {
  16.             pref+='twitter.search.user ';
  17.           }
  18.         }
  19.  
  20.       }
  21.       this.prefMan.setValue('disabledSiteTypes',pref);
  22.       
  23.       var scale=document.getElementById('font-size');
  24.       this.prefMan.setValue('fontSize',scale.value);
  25.       
  26.       var maxTags=document.getElementById('max-tags');
  27.       this.prefMan.setValue('maxTags',maxTags.value);
  28.       
  29.       var doubleLinks=document.getElementById('doublelinks');
  30.       this.prefMan.setValue('useDoubleLinks',doubleLinks.checked);
  31.       
  32.       var doubleLinksColor=document.getElementById('doublelinkscolor');
  33.       this.prefMan.setValue('changeDLColor',doubleLinksColor.checked);
  34.       
  35.       var useSCSC=document.getElementById('useSCSC');
  36.       this.prefMan.setValue('useSCSC',useSCSC.checked);
  37.  
  38.  
  39.       //alert(this.prefMan.getValue('disabledSiteTypes'));
  40.     },
  41.     doCancel:function()
  42.     {
  43.       //alert('Cancel');
  44.     },
  45.     init:function()
  46.     {
  47.       this.prefMan=new tagcloudjs_PrefManager();
  48.       var pref=this.prefMan.getValue('disabledSiteTypes','');
  49.       var elems=pref.split(' ');
  50.       for(var i=0;i<elems.length;i++)
  51.       {
  52.         if (elems[i] && elems[i].length>0)
  53.         {
  54.           document.getElementById(elems[i]).checked=false;
  55.         }
  56.       }
  57.       
  58.       var scale=document.getElementById('font-size');
  59.       scale.value=this.prefMan.getValue('fontSize',100);
  60.       
  61.       this.updateFonts(scale.value);
  62.       
  63.       var maxTags=document.getElementById('max-tags');
  64.       maxTags.value=this.prefMan.getValue('maxTags',50);
  65.       
  66.       var doubleLinks=document.getElementById('doublelinks');
  67.       doubleLinks.checked=this.prefMan.getValue('useDoubleLinks',true);
  68.       
  69.       var doubleLinksColor=document.getElementById('doublelinkscolor');
  70.       doubleLinksColor.checked=this.prefMan.getValue('changeDLColor',true);
  71.       doubleLinksColor.disabled=!doubleLinks.checked;
  72.       
  73.       
  74.       var useSCSC=document.getElementById('useSCSC');
  75.       useSCSC.checked=this.prefMan.getValue('useSCSC',false);
  76.  
  77.       
  78.  
  79.     },
  80.     doDefault:function()
  81.     {
  82.       var scale=document.getElementById('font-size');
  83.       scale.value=100;
  84.       
  85.       this.updateFonts(scale.value);
  86.       
  87.       var maxTags=document.getElementById('max-tags');
  88.       maxTags.value=50;
  89.  
  90.       
  91.     },
  92.     fontSizeChanged:function()
  93.     {
  94.       var scale=document.getElementById('font-size');
  95.       var val=scale.value;
  96.       
  97.       this.updateFonts(val);
  98.  
  99.  
  100.     },
  101.     updateFonts:function(val)
  102.     {
  103.       var label=document.getElementById('percents');
  104.       label.value=val+'%';
  105.       
  106.       var small=document.getElementById('small-tag');
  107.       small.setAttribute("style","font-size:"+Math.round(12*val/100)+"px;");
  108.       
  109.       var medium=document.getElementById('medium-tag');
  110.       medium.setAttribute("style","font-size:"+Math.round(27*val/100)+"px;");
  111.       
  112.       var large=document.getElementById('large-tag');
  113.       large.setAttribute("style","font-size:"+Math.round(42*val/100)+"px;");
  114.     },
  115.     doubleLinksChecked:function()
  116.     {
  117.       var doubleLinks=document.getElementById('doublelinks');
  118.       var doubleLinksColor=document.getElementById('doublelinkscolor');
  119.       if (doubleLinks.checked)
  120.       {
  121.           doubleLinksColor.disabled=false;
  122.       }
  123.       else
  124.       {
  125.           doubleLinksColor.disabled=true;
  126.       }
  127.  
  128.     },
  129.     dlMouseOver:function(e)
  130.      {
  131.        var obj=(e.srcElement)?e.srcElement:(e.target)?e.target:null;
  132.        if (!obj.id) return true;
  133.        var parts=obj.id.split('-');
  134.        if (parts[0].indexOf('dl')!=0) return true;
  135.  
  136.        
  137.        var myId=parts[0]+'-'+parts[1];
  138.        var otherId=parts[0]+'-'+(1-parts[1]);
  139.        
  140.        var changeColor=document.getElementById('doublelinkscolor').checked;
  141.              
  142.        var me=document.getElementById(myId);
  143.        var other=document.getElementById(otherId);
  144.        if (0==parts[1])
  145.        {
  146.          var style="text-decoration: underline;";
  147.        }
  148.        else
  149.        {
  150.          var style="text-decoration: line-through;";
  151.          if (changeColor)
  152.          {
  153.            style+="color:red;";
  154.          }
  155.        }
  156.        
  157.        me.setAttribute('style',style);
  158.        other.setAttribute('style',style);
  159.        
  160.        /*var myText=document.getElementById('dltext-'+parts[1]);
  161.        var otherText=document.getElementById('dltext-'+(1-parts[1]));
  162.        myText.setAttribute('style','font-weight:bold;');
  163.        otherText.setAttribute('style','');*/
  164.  
  165.      },
  166.  
  167.      dlMouseOut:function(e)
  168.      {
  169.        var obj=(e.srcElement)?e.srcElement:(e.target)?e.target:null;
  170.        if (!obj.id) return;
  171.        var parts=obj.id.split('-');
  172.        if (parts[0].indexOf('dl')!=0) return true;
  173.  
  174.        var myId=parts[0]+'-'+parts[1];
  175.        var otherId=parts[0]+'-'+(1-parts[1]);
  176.              
  177.        var me=document.getElementById(myId);
  178.        var other=document.getElementById(otherId);
  179.        
  180.        me.setAttribute('style','');
  181.        other.setAttribute('style','');
  182.        
  183.        /*var myText=document.getElementById('dltext-'+parts[1]);
  184.        var otherText=document.getElementById('dltext-'+(1-parts[1]));
  185.        myText.setAttribute('style','');
  186.        otherText.setAttribute('style','');*/
  187.  
  188.      },
  189.      dlMouseClick:function(e)
  190.      {
  191.        var obj=(e.srcElement)?e.srcElement:(e.target)?e.target:null;
  192.        if (!obj.id) return;
  193.        var parts=obj.id.split('-');
  194.  
  195.        var myText=document.getElementById('dltext-'+parts[1]);
  196.        var otherText=document.getElementById('dltext-'+(1-parts[1]));
  197.        myText.setAttribute('style','font-weight:bold;');
  198.        otherText.setAttribute('style','');
  199.        return false;
  200.  
  201.      }
  202.  
  203.  
  204. };